<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <h3>axios</h3>
  <div>
    <button id="set-btn">设置cookie</button>
    <button id="get-btn">获取cookie</button>
  </div>
  <div>
    <ol>
      <li>注意后台的cookie 设置了有效时间，时间到了  cookie就没有了</li>
      <li>cookie签名以后，就是一堆乱七八糟的东西，记得要给app.use(cookieParser("miyao")) 传递一个字符串签名参数</li>
    </ol>
  </div>
  <script src="https://cdn.bootcss.com/axios/0.19.2/axios.js"></script>
  <script>

    document.cookie="a=b"

    let s1 = document.querySelector("#set-btn")
    let s2 = document.querySelector("#get-btn")

    s1.addEventListener("click", handelSet, false)
    s2.addEventListener("click", handelGet, false)

    function  handelSet() {
      axios({
        url: "/set-cookie",
        withCredentials: true
      }).then(res=> {
        console.log(res);
      }).catch(err=> {
        console.log(err)
      })
    }

    function  handelGet() {
      axios({
        url: "/get-cookie"
      }).then(res=> {
        console.log(res);
      }).catch(err=> {
        console.log(err)
      })
    }

    
  </script>
</body>
</html>